package com.zhuiyun.pm.client.interest.mapper;

import com.zhuiyun.pm.client.interest.entity.ClientInterest;
import com.zhuiyun.pm.config.BaseMapper;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface ClientInterestMapper extends BaseMapper<ClientInterest> {

    /**
     * 查询被关注信息
     * @author 温
     * @date 2023/3/23 16:18
     * @parameter [userId, uId]
     * @return com.zhuiyun.pm.client.interest.entity.ClientInterest
     */
    @Select("select* from client_interest\n" +
            "where user_id=#{userId} and uu_id = #{uuId}")
    @Results({
            @Result(property = "userId" , column = "user_id"),
            @Result(property = "uuId" , column = "uu_id"),
    })
    ClientInterest clientInterestList(@Param("userId") int  userId,@Param("uuId") int uuId);

    /**
     * 取消关注
     * @author 温
     * @date 2023/3/23 16:17
     * @parameter [userId, uId]
     * @return int
     */
    @Delete("delete from client_interest where user_id=#{userId} and uu_id=#{uuId}")
    int  clientInterestDel(@Param("userId") int userId,@Param("uuId") int uuId);


    /**
     * 关注
     * @author 温
     * @date 2023/3/23 18:38
     * @parameter [clientInterest]
     * @return int
     */
    @Insert("insert into client_interest ( user_id,uu_id) values(#{userId},#{uuId})")
    int clientInterestAdd(ClientInterest clientInterest);

    /**
     * 查询粉丝数量
     * @author 温
     * @date 2023/3/23 19:09
     * @parameter
     * @return
     */
    @Select("select COUNT(*) from client_interest where uu_id = #{uuId}")
    Integer  clientInterest(int uuId);
}
